﻿//********************************************************************************//
//创建日期：<创建日期，2016-05-12>
//创建作者：<孙雪婷，sunxueting@shanghai3h.com>
//功能说明：计划查询
//********************************************************************************//
using BLL;
using BLL.Access;
using DevExpress.Web;
using Entity;
using System;
using System.Data;
using Web.Class;

namespace Web.Pages.YongShui._12.ChaXunGL
{
    public partial class JiHuaCX_YB : BasePage
    {
        #region 属性

        /// <summary>
        /// 保存结果集1
        /// </summary>
        private DataTable dtYongHuXXTab1
        {
            get
            {
                return ViewState["dtYongHuXXTab1"] as DataTable;
            }
            set
            {
                ViewState["dtYongHuXXTab1"] = value;
            }
        }

        /// <summary>
        /// 保存结果集2
        /// </summary>
        private DataTable dtXiaDaJHTab2
        {
            get
            {
                return ViewState["dtXiaDaJHTab2"] as DataTable;
            }
            set
            {
                ViewState["dtXiaDaJHTab2"] = value;
            }
        }

        /// <summary>
        /// 保存结果集3
        /// </summary>
        private DataTable dtYuanJHTab3
        {
            get
            {
                return ViewState["dtYuanJHTab3"] as DataTable;
            }
            set
            {
                ViewState["dtYuanJHTab3"] = value;
            }
        }

        /// <summary>
        /// 保存结果集4
        /// </summary>
        private DataTable dtJiJianJHTab4
        {
            get
            {
                return ViewState["dtJiJianJHTab4"] as DataTable;
            }
            set
            {
                ViewState["dtJiJianJHTab4"] = value;
            }
        }

        /// <summary>
        /// 保存结果集5
        /// </summary>
        private DataTable dtYueTZTab5
        {
            get
            {
                return ViewState["dtYueTZTab5"] as DataTable;
            }
            set
            {
                ViewState["dtYueTZTab5"] = value;
            }
        }

        /// <summary>
        /// 当前操作项ID
        /// </summary>
        private int yonghuXXTab1_ID
        {
            get
            {
                return Convert.ToInt32(ViewState["yonghuXXTab1_ID"]);
            }
            set
            {
                ViewState["yonghuXXTab1_ID"] = value;
            }
        }
        /// <summary>
        /// 当前操作项ID
        /// </summary>
        private int XiaDaJHTab2_ID
        {
            get
            {
                return Convert.ToInt32(ViewState["XiaDaJHTab2_ID"]);
            }
            set
            {
                ViewState["XiaDaJHTab2_ID"] = value;
            }
        }

        /// <summary>
        /// 当前操作项ID
        /// </summary>
        private string YuanJiHtab3_ID
        {
            get
            {
                return ViewState["YuanJiHtab3_ID"] as string;
            }
            set
            {
                ViewState["YuanJiHtab3_ID"] = value;
            }
        }

        /// <summary>
        /// 当前操作项ID
        /// </summary>
        private int  JiJianJHtab4_ID
        {
            get
            {
                return Convert.ToInt32(ViewState["JiJianJHtab4_ID"]);
            }
            set
            {
                ViewState["JiJianJHtab4_ID"] = value;
            }
        }

        /// <summary>
        /// 当前操作项ID
        /// </summary>
        private int YueTZtab5_ID
        {
            get
            {
                return Convert.ToInt32(ViewState["YueTZtab5_ID"]);
            }
            set
            {
                ViewState["YueTZtab5_ID"] = value;
            }
        }
        /// <summary>
        /// 水量月
        /// </summary>
        private int I_M
        {
            get
            {
                return Convert.ToInt32(ViewState["I_M"]);
            }
            set
            {
                ViewState["I_M"] = value;
            }
        }
        /// <summary>
        /// 水量年
        /// </summary>
        private int I_Y
        {
            get
            {
                return Convert.ToInt32(ViewState["I_Y"]);
            }
            set
            {
                ViewState["I_Y"] = value;
            }
        }

        #endregion

        #region 变量

        /// </summary>
        /// 用户信息bll
        /// </summary>
        YS_YG_YONGHUXXBLL _YS_YG_YONGHUXXBLL = new YS_YG_YONGHUXXBLL();

        /// <summary>
        /// 管理部门bll
        /// </summary>
        YS_JX_ZHANDIANBLL _YS_JX_ZHANDIANBLL = new YS_JX_ZHANDIANBLL();

        /// <summary>
        /// 管理块BLL
        /// </summary>
        YS_JX_GUANLIKBLL _YS_JX_GUANLIKBLL = new YS_JX_GUANLIKBLL();

        /// <summary>
        /// 局信息BLL
        /// </summary>
        YS_JX_JUXINXBLL _YS_JX_JUXINXBLL = new YS_JX_JUXINXBLL();

        /// <summary>
        /// 公司信息BLL
        /// </summary>
        YS_JX_GONGSIXXBLL _YS_JX_GONGSIXXBLL = new YS_JX_GONGSIXXBLL();

        /// <summary>
        /// 存储过程调用类
        /// </summary>
        SpHelper _SpHelper = new SpHelper();

        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //第一次页面加载
            if (!IsPostBack)
            {
                InitData();
            }
            //switch (ASPxPageControl1.ActiveTabIndex)
            //{
            //    case 0:
            gvYongHuXXTab1.DataSource = this.dtYongHuXXTab1;
            gvYongHuXXTab1.DataBind();
            //        break;
            //    case 1:
            //        this.gvXiaDaJHTab2.DataSource = this.dtXiaDaJHTab2;
            //        this.gvXiaDaJHTab2.DataBind();
            //        break;
            //    case 2:
            //        this.gvYuanJiHTab3.DataSource = this.dtYuanJHTab3;
            //        this.gvYuanJiHTab3.DataBind();
            //        break;
            //    case 3:
            //        this.gvJiJianJHTab4.DataSource = this.dtJiJianJHTab4;
            //        this.gvJiJianJHTab4.DataBind();
            //        break;
            //    case 4:
            //        this.gvYueTZTab5.DataSource = this.dtYueTZTab5;
            //        this.gvYueTZTab5.DataBind();
            //        break;
            //    default: break;
            //}
            //ClearDataSource(ASPxPageControl1.ActiveTabIndex);
        }

        ///// <summary>
        ///// 绑定空表头
        ///// </summary>
        //protected override void Render(HtmlTextWriter sender)
        //{
        //    DataTable dt = _YS_YG_YONGHUXXBLL.SelectYS_YG_YONGHUXXesDynamic("1=0", "", null);
        //    base.Render(sender);
        //}

        /// <summary>
        /// 查询信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnChaXun_Click(object sender, EventArgs e)
        {
            //20190411 add 只能查询用户信息选项卡
            if (ASPxPageControl1.ActiveTabIndex != 0)
            {
                PageTools.AlertMsg(this, "请在用户信息选项卡中选择用户.");
                return;
            }
            zjltab1.Text = "共0条";
            zjltab3.Text = "共0条";
            if (//txtShuiLiangYM.Text != "" && txtShuiLiangYM.Text != null)
                1 == 1)
            {
                int v_ym = 0;
                if (!int.TryParse(txtShuiLiangYM.Text, out v_ym))
                {
                    v_ym = 0;
                }
                this.I_Y = v_ym / 100;
                this.I_M = v_ym % 100;
                //站点
                string v_zhandian = cmbGuanLiBM.Text != "" ? cmbGuanLiBM.Value.ToString() : null ;
                string v_guanlikuai = "", v_yonghuh = "", v_yonghum = "", v_yonghudz = "";
                int biaoshi = -1;
                string conStr = "";

                //管理块
                if (cmbGuanLiK.Value != null)
                {
                    v_guanlikuai = cmbGuanLiK.Value.ToString();
                }

                //用户号、用户名、用户地址
                if (rbnYongHuH.Checked && txtYongHuH.Text != "")
                {
                    hidName.Value = "0";
                    //HidValue.Value = txtYongHuH.Text;
                    biaoshi = 0;
                    conStr = txtYongHuH.Text;
                    v_yonghuh = txtYongHuH.Text;
                }
                else if (rbnYongHuM.Checked && txtYongHuM.Text != "")
                {
                    hidName.Value = "1";
                    //HidValue.Value = txtYongHuM.Text;
                    biaoshi = 1;
                    conStr = txtYongHuM.Text;
                    v_yonghum = txtYongHuM.Text;
                }
                else if (rbnYongHuDZ.Checked && txtYongHuDZ.Text != "")
                {
                    hidName.Value = "2";
                    //HidValue.Value = txtYongHuDZ.Text;
                    biaoshi = 2;
                    conStr = txtYongHuDZ.Text;
                    v_yonghudz = txtYongHuDZ.Text;
                }
                LoadGridDataTab1(v_zhandian, v_guanlikuai, v_yonghuh, v_yonghum, v_yonghudz, v_ym);

            }
        }

        /// <summary>
        /// 管理部门下拉改变事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void cmbGuanLiBM_SelectedIndexChanged(object sender, EventArgs e)
        {
            cmbGuanLiK.Items.Clear();
            cmbGuanLiK.Items.Add("全部", "");
            cmbGuanLiK.SelectedIndex = 0;
            string glbm_now = cmbGuanLiBM.Value != null ? cmbGuanLiBM.Value.ToString() : "全部";
            InitDataAgain(glbm_now);
        }

        #region 暂时不用的后台行点击事件
        ///// <summary>
        ///// 表格点击行事件
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //protected void gvYongHuXXTab1_FocusedRowChanged(object sender, EventArgs e)
        //{
        //    if (this.dtYongHuXXTab1 != null && this.dtYongHuXXTab1.Rows.Count > 0)
        //    {
        //        this.yonghuXXTab1_ID = Convert.ToInt32(this.gvYongHuXXTab1.GetRowValues(this.gvYongHuXXTab1.FocusedRowIndex, "ID"));
        //        SetDataTab1();
        //    }
        //}

        /// <summary>
        /// 列表列点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //protected void gvXiaDaJHTab2_FocusedRowChanged(object sender, EventArgs e)
        //{
        //    if (this.dtXiaDaJHTab2 != null && this.dtXiaDaJHTab2.Rows.Count > 0)
        //    {
        //        this.XiaDaJHTab2_ID = Convert.ToInt32(this.gvXiaDaJHTab2.GetRowValues(this.gvXiaDaJHTab2.FocusedRowIndex, "ID"));
        //        SetDataTab2();
        //    }
        //}

        /// <summary>
        /// tab3行点击切换事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //protected void gvYuanJiHTab3_FocusedRowChanged(object sender, EventArgs e)
        //{
        //    if (this.dtYuanJHTab3 != null && this.dtYuanJHTab3.Rows.Count > 0)
        //    {
        //        this.YuanJiHtab3_ID = this.gvYuanJiHTab3.GetRowValues(this.gvYuanJiHTab3.FocusedRowIndex, "S_YONGHUH").ToString();
        //        SetDataTab3();
        //    }
        //}

        /// <summary>
        /// tab4行点击切换事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //protected void gvJiJianJHTab4_FocusedRowChanged(object sender, EventArgs e)
        //{
        //    if (this.dtJiJianJHTab4 != null && this.dtJiJianJHTab4.Rows.Count > 0)
        //    {
        //        this.JiJianJHtab4_ID = Convert.ToInt32(this.gvJiJianJHTab4.GetRowValues(this.gvJiJianJHTab4.FocusedRowIndex, "ID"));
        //        SetDataTab4();
        //    }
        //}
        #endregion

        #endregion

        #region 方法

        private void ClearDataSource(int index)
        {
            //if (index != 0)
            //{
            //    dtYongHuXXTab1 = null;
            //}
            if (index != 1)
            { dtXiaDaJHTab2 = null; }
            if (index != 2)
            { dtYuanJHTab3 = null; }
            if (index != 3)
            { dtJiJianJHTab4 = null; }
            if (index != 4)
            { dtYueTZTab5 = null; }
          
        }

        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {
            gvYongHuXXTab1.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            gvYuanJiHTab3.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            //水量年月
            string water_y_m = BusinessTool.YS_GETSETTINGSVALUE(eSETTINGS_KEYNAME.WATER_Y_M.ToString());
            //管理部门
            DataTable dtGuanLiBM = _YS_JX_ZHANDIANBLL.SelectYS_JX_ZHANDIANsAll();
            for (int i = 0; i < dtGuanLiBM.Rows.Count; i++)
            {
                if (dtGuanLiBM.Rows[i]["S_ZHANDIANMC"].ToString() != "中心")
                {
                    cmbGuanLiBM.Items.Add(dtGuanLiBM.Rows[i]["S_ZHANDIANMC"].ToString(), dtGuanLiBM.Rows[i]["S_ZHANDIANBH"].ToString());
                }
            }

            //业务员
            LoadYWY();
            txtShuiLiangYM.Text = water_y_m;

            //加载局信息和公司信息
            LoadJXX_GSXX();

            int userid = LoginInfo.CurrentUser.UserID;
            string username = LoginInfo.CurrentUser.UserName;
            //根据操作人加载管理部门(站点)
            DataTable dtZhanDian = BusinessTool.GetTextAndValue("View_AS_UserInfo", "ZHANDIANBH", "ROLEID", null, string.Format("USERID={0}", userid)).Tables[0];
            string zhandian = dtZhanDian.Rows[0]["TEXT"].ToString();//站点
            string roleid = dtZhanDian.Rows[0]["VALUE"].ToString();//9001 业务员，3001 办事处主任
            if (roleid == "9001")
            {
                if (zhandian == "00")
                {
                    cmbYeWuY.Enabled = false;
                    cmbYeWuY.Text = username;
                }
                else
                {
                    cmbGuanLiBM.Enabled = false;
                    cmbYeWuY.Enabled = false;
                    cmbGuanLiBM.Value = zhandian;
                    cmbYeWuY.Text = username;
                    //管理块
                    DataTable dtGuanLiK = _YS_JX_GUANLIKBLL.SelectYS_JX_GUANLIKsDynamic(string.Format("S_ZHANDIAN={0}", zhandian), null);
                    for (int i = 0; i < dtGuanLiK.Rows.Count; i++)
                    {
                        cmbGuanLiK.Items.Add(dtGuanLiK.Rows[i]["S_GUANLIKMC"].ToString(), dtGuanLiK.Rows[i]["S_GUANLIKH"].ToString());
                    }
                }
            }
            else if (roleid == "3001" || roleid == "4001")
            {
                cmbGuanLiBM.Enabled = false;
                cmbGuanLiBM.Value = zhandian;
                //管理块
                DataTable dtGuanLiK = _YS_JX_GUANLIKBLL.SelectYS_JX_GUANLIKsDynamic(string.Format("S_ZHANDIAN={0}", zhandian), null);
                for (int i = 0; i < dtGuanLiK.Rows.Count; i++)
                {
                    cmbGuanLiK.Items.Add(dtGuanLiK.Rows[i]["S_GUANLIKMC"].ToString(), dtGuanLiK.Rows[i]["S_GUANLIKH"].ToString());
                }
                LoadYWY();
            }
        }

        /// <summary>
        /// 根据站点加载业务员
        /// </summary>
        private void LoadYWY()
        {
            DataTable dtYWY = BusinessTool.GetTextAndValue(
                "View_AS_UserInfo", "USERNAME", "USERID", null, this.cmbGuanLiBM.SelectedIndex == 0 ? "ROLENAME like '%业务员%'" : string.Format("ZHANDIANBH='{0}' and ROLENAME like '%业务员%'", this.cmbGuanLiBM.Value)
                 ).Tables[0];
            DataRow drTemp = dtYWY.NewRow();
            drTemp[0] = "";
            drTemp[1] = 0;
            dtYWY.Rows.InsertAt(drTemp, 0);
            PageTools.BindComboBox(
                this.cmbYeWuY, dtYWY
            );
            if (this.cmbYeWuY.Items.Count != 0)
            {
                this.cmbYeWuY.SelectedIndex = 0;
            }
        }

        /// <summary>
        /// 加载局信息和公司信息
        /// </summary>
        private void LoadJXX_GSXX()
        {
            DataTable dt_jxx = _YS_JX_JUXINXBLL.SelectYS_JX_JUXINXesDynamic("i_leixing=0 and i_jlzt=0", null);
            for (int i = 0; i < dt_jxx.Rows.Count; i++)
            {
                cbmJuXX.Items.Add(dt_jxx.Rows[i]["S_BIANHAO"].ToString() + "_" + dt_jxx.Rows[i]["S_MINGCHENG"].ToString(), dt_jxx.Rows[i]["S_BIANHAO"]);
            }
            cbmJuXX.Items.Insert(0,new ListEditItem("","-1"));
            DataTable dt_gsxx = _YS_JX_GONGSIXXBLL.SelectYS_JX_GONGSIXXesDynamic("i_leixing=0 and i_jlzt=0", null);
            for (int i = 0; i < dt_gsxx.Rows.Count; i++)
            {
                cmbGongSiXX.Items.Add(dt_gsxx.Rows[i]["S_BIANHAO"].ToString() + "_" + dt_gsxx.Rows[i]["S_MINGCHENG"].ToString(), dt_gsxx.Rows[i]["S_BIANHAO"]);
            }
            cmbGongSiXX.Items.Insert(0, new ListEditItem("", "-1"));
        }

        /// <summary>
        /// 再次根据管理部门初始化查询条件
        /// </summary>
        /// <param name="glbm">管理部门</param>
        private void InitDataAgain(string glbm)
        {
            if (glbm != "全部")
            {
                //管理块
                DataTable dtGuanLiK = _YS_JX_GUANLIKBLL.SelectYS_JX_GUANLIKsDynamic(string.Format("S_ZHANDIAN={0}", glbm), null);
                for (int i = 0; i < dtGuanLiK.Rows.Count; i++)
                {
                    cmbGuanLiK.Items.Add(dtGuanLiK.Rows[i]["S_GUANLIKMC"].ToString(), dtGuanLiK.Rows[i]["S_GUANLIKH"].ToString());
                }
                //业务员
                LoadYWY();
            }
            {
                cmbYeWuY.Items.Clear();
                //业务员
                LoadYWY();
            }

        }

        /// <summary>
        /// 加载查询数据
        /// </summary>
        private void LoadGridDataTab1(string v_zhandian, string v_guanlikuai, string v_yonghuh, string v_yonghum, string v_yonghudz, int v_ym)
        {
            if (v_zhandian == "全部")
            {
                v_zhandian = "";
            }
            string v_juxx = "", v_ywy = "", v_gongsixx = "";
            if (rbnJuXX.Checked && cbmJuXX.Text != "" && cbmJuXX.Value.ToString() != "-1")//局信息
            {
                v_juxx = cbmJuXX.Value.ToString();
            }
            else if (rbnGongSiXX.Checked && cmbGongSiXX.Text != "" && cmbGongSiXX.Value.ToString() != "-1")//公司信息
            {
                v_gongsixx = cmbGongSiXX.Value.ToString();
            }
            else if (rbnYeWuY.Checked && cmbYeWuY.Text != "" && Convert.ToInt32(cmbYeWuY.Value.ToString()) > 0)//业务员
            {
                v_ywy = cmbYeWuY.Value.ToString();
            }
            dtYongHuXXTab1 = null;
            this.dtYongHuXXTab1 = _SpHelper.P_YSCX_YHXXCX_YB(v_zhandian, v_guanlikuai, v_ywy, v_ym, v_yonghuh, v_yonghum, v_yonghudz,
                2, "", "", "", "", v_juxx, v_gongsixx, "", "", 0, "").Tables[0];
            gvYongHuXXTab1.DataSource = this.dtYongHuXXTab1;
            gvYongHuXXTab1.DataBind();
            if (this.dtYongHuXXTab1 != null && this.dtYongHuXXTab1.Rows.Count > 0)
            {
                zjltab1.Text = "共" + this.dtYongHuXXTab1.Rows.Count.ToString() + "条";
                gvYongHuXXTab1.FocusedRowIndex = -1;
                gvYongHuXXTab1.FocusedRowIndex = 0;
                //string yhh = this.dtYongHuXXTab1.Rows[0]["用户号"].ToString();
                //if (yhh != "")
                //{
                //    //HidValue.Value = txtYongHuM.Text;
                //    LoadGridDataTab2(yhh);
                //    LoadGridDataTab3("全部", "", 0, yhh);
                //    LoadGridDataTab4(yhh);
                //    LoadGridDataTab5(yhh);
                //}
            }
            else {
                txtYongHuH2.Text = "";
                txtYongHuM2.Text = "";
                txtJuHao.Text = "";
                txtJuMing.Text = "";
                txtYongShuiJ2.Text = "";
                txtSheShuiDXFL.Text = "";
                txtGongSiH.Text = "";
                txtGongSiM.Text = "";
                txtYeWuY.Text = "";
                txtZiLaiSBS.Text = "0";
                txtHuiGuanBS.Text = "";
                txtShiKaoHY2.Text = "";
                txtYongHuDZ2.Text = "";
                txtKaiHuHM2.Text = "";
                txtKaiHuYH.Text = "";
                txtYinHangZH2.Text = "";
            }
        }

        /// <summary>
        /// 给TAB1显示框赋值
        /// </summary>
        private void SetDataTab1()
        {
            int id = Convert.ToInt32(hidYhh_id.Value);
            DataTable dt_temp = _SpHelper.P_YSCX_YHXXCX_YB("", "", "", Convert.ToInt32(txtShuiLiangYM.Text), "", "", "", 2, "", "", "", "", "", "", "", "", id, "").Tables[0];
            if (dt_temp != null && dt_temp.Rows.Count > 0)
            {
                txtYongHuH2.Text = dt_temp.Rows[0]["用户号"].ToString();
                txtYongHuM2.Text = dt_temp.Rows[0]["用户名"].ToString();
                txtJuHao.Text = dt_temp.Rows[0]["局号"].ToString();
                txtJuMing.Text = dt_temp.Rows[0]["局名"].ToString();
                txtYongShuiJ2.Text = dt_temp.Rows[0]["用水价"].ToString();
                txtSheShuiDXFL.Text = dt_temp.Rows[0]["S_SHESHUIDXFLMC"].ToString();
                txtGongSiH.Text = dt_temp.Rows[0]["公司号"].ToString();
                txtGongSiM.Text = dt_temp.Rows[0]["公司名"].ToString();
                txtYeWuY.Text = dt_temp.Rows[0]["业务员"].ToString();
                txtZiLaiSBS.Text = dt_temp.Rows[0]["I_ZLSBS"].ToString();
                txtHuiGuanBS.Text = dt_temp.Rows[0]["I_HGBS"].ToString();
                txtShiKaoHY2.Text = dt_temp.Rows[0]["试考核月"].ToString();//20190408 考核复用改为试考核月
                txtYongHuDZ2.Text = dt_temp.Rows[0]["用户地址"].ToString();
                txtKaiHuHM2.Text = dt_temp.Rows[0]["开户户名"].ToString();
                txtKaiHuYH.Text = dt_temp.Rows[0]["开户银行"].ToString();
                txtYinHangZH2.Text = dt_temp.Rows[0]["银行账号"].ToString();
            }
        }
        

        /// <summary>
        /// 加载tab3页签数据
        /// </summary>
        private void LoadGridDataTab3(string v_zhandian, string v_guanlikuai, int biaoshi, string conStr)
        {
            this.dtYuanJHTab3 = _SpHelper.P_YSCX_JHCX_YJH(v_zhandian, v_guanlikuai, this.I_Y, biaoshi, conStr, this.I_M, 0).Tables[0];
            this.gvYuanJiHTab3.DataSource = this.dtYuanJHTab3;
            this.gvYuanJiHTab3.DataBind();
            if (this.dtYuanJHTab3 != null && this.dtYuanJHTab3.Rows.Count > 0)
            {
                zjltab3.Text = "共" + this.dtYuanJHTab3.Rows.Count.ToString() + "条";
                gvYuanJiHTab3.FocusedRowIndex = -1;
                gvYuanJiHTab3.FocusedRowIndex = 0;
            }
            else {
                txtYongHuHtab3.Text = "";
                txtYongHuMtab3.Text = "";
                txtYiYueTab3.Text = "";
                txtErYueTab3.Text = "";
                txtSanYueTab3.Text = "";
                txtSiYueTab3.Text = "";
                txtWuYueTab3.Text = "";
                txtLiuYueTab3.Text = "";
                txtQiYueTab3.Text = "";
                txtBaYueTab3.Text = "";
                txtJiuYueTab3.Text = "";
                txtShiYueTab3.Text = "";
                txtShiYiYueTab3.Text = "";
                txtShiErYueTab3.Text = "";
                txtQuanNianHJtab3.Text = "";
            }
        }

        /// <summary>
        /// 给tab3页签的显示框赋值
        /// </summary>
        private void SetDataTab3() 
        {
            //ClearTxtValue();
            //DataTable dt_temp_tab3 =  _SpHelper.P_YSCX_JHCX_YJH("", "", this.I_Y, 0, this.YuanJiHtab3_ID, this.I_M, 0).Tables[0];
            //if (dt_temp_tab3 != null && dt_temp_tab3.Rows.Count > 0)
            //{
            //    txtYongHuHtab3.Text = dt_temp_tab3.Rows[0]["S_YONGHUH"].ToString();
            //    txtYongHuMtab3.Text = dt_temp_tab3.Rows[0]["S_YONGHUM"].ToString();
            //    txtYiYueTab3.Text = dt_temp_tab3.Rows[0]["I_M1"].ToString();
            //    txtErYueTab3.Text = dt_temp_tab3.Rows[0]["I_M2"].ToString();
            //    txtSanYueTab3.Text = dt_temp_tab3.Rows[0]["I_M3"].ToString();
            //    txtSiYueTab3.Text = dt_temp_tab3.Rows[0]["I_M4"].ToString();
            //    txtWuYueTab3.Text = dt_temp_tab3.Rows[0]["I_M5"].ToString();
            //    txtLiuYueTab3.Text = dt_temp_tab3.Rows[0]["I_M6"].ToString();
            //    txtQiYueTab3.Text = dt_temp_tab3.Rows[0]["I_M7"].ToString();
            //    txtBaYueTab3.Text = dt_temp_tab3.Rows[0]["I_M8"].ToString();
            //    txtJiuYueTab3.Text = dt_temp_tab3.Rows[0]["I_M9"].ToString();
            //    txtShiYueTab3.Text = dt_temp_tab3.Rows[0]["I_M10"].ToString();
            //    txtShiYiYueTab3.Text = dt_temp_tab3.Rows[0]["I_M11"].ToString();
            //    txtShiErYueTab3.Text = dt_temp_tab3.Rows[0]["I_M12"].ToString();
            //    txtQuanNianHJtab3.Text = dt_temp_tab3.Rows[0]["I_HEJI"].ToString();
            //}
        }

        
       
      
       
        
        /// <summary>
        /// 前台表格行改变事件回调方法
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void ASPxCallback1_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        {
            object id = this.hdCollection.Get("ID");
            string msg = "";
            if (e.Parameter == "setinfo")
            {
                DataTable dt_temp = _SpHelper.P_YSCX_YHXXCX_YB("", "", "", Convert.ToInt32(txtShuiLiangYM.Text), "", "", "", 2, "", "", "", "", "", "", "", "", Convert.ToInt32(id), "").Tables[0];
                if (dt_temp != null && dt_temp.Rows.Count > 0)
                {
                    msg = string.Join("|", Convert.ToString(dt_temp.Rows[0]["用户号"]), Convert.ToString(dt_temp.Rows[0]["用户名"]),
                        Convert.ToString(dt_temp.Rows[0]["局号"]), Convert.ToString(dt_temp.Rows[0]["局名"]), Convert.ToString(dt_temp.Rows[0]["用水价"]), Convert.ToString(dt_temp.Rows[0]["S_SHESHUIDXFLMC"]),
                        Convert.ToString(dt_temp.Rows[0]["公司号"]), Convert.ToString(dt_temp.Rows[0]["公司名"]), Convert.ToString(dt_temp.Rows[0]["业务员"]),
                        Convert.ToString(dt_temp.Rows[0]["试考核月"]),//考核复用改为试考核月 20190408
                        Convert.ToString(dt_temp.Rows[0]["用户地址"]), Convert.ToString(dt_temp.Rows[0]["开户户名"]), Convert.ToString(dt_temp.Rows[0]["开户银行"]), Convert.ToString(dt_temp.Rows[0]["银行账号"]),
                        dt_temp.Rows[0]["I_ZLSBS"].ToString(), dt_temp.Rows[0]["I_HGBS"].ToString());
                }

            }
            
            else if (e.Parameter == "yjh")
            {
                DataTable dt_temp_tab3 = null;
                dt_temp_tab3 = _SpHelper.P_YSCX_JHCX_YJH("", "", this.I_Y, 0, id.ToString(), this.I_M, 0).Tables[0];

                if (dt_temp_tab3 != null && dt_temp_tab3.Rows.Count > 0)
                {
                    msg = string.Join("|", Convert.ToString(dt_temp_tab3.Rows[0]["S_YONGHUH"]), Convert.ToString(dt_temp_tab3.Rows[0]["S_YONGHUM"]), Convert.ToString(dt_temp_tab3.Rows[0]["I_M1"]),
                         Convert.ToString(dt_temp_tab3.Rows[0]["I_M2"]), Convert.ToString(dt_temp_tab3.Rows[0]["I_M3"]), Convert.ToString(dt_temp_tab3.Rows[0]["I_M4"]),
                         Convert.ToString(dt_temp_tab3.Rows[0]["I_M5"]), Convert.ToString(dt_temp_tab3.Rows[0]["I_M6"]), Convert.ToString(dt_temp_tab3.Rows[0]["I_M7"]),
                         Convert.ToString(dt_temp_tab3.Rows[0]["I_M8"]), Convert.ToString(dt_temp_tab3.Rows[0]["I_M9"]), Convert.ToString(dt_temp_tab3.Rows[0]["I_M10"]),
                         Convert.ToString(dt_temp_tab3.Rows[0]["I_M11"]), Convert.ToString(dt_temp_tab3.Rows[0]["I_M12"]), Convert.ToString(dt_temp_tab3.Rows[0]["I_HEJI"]));
                }
            }
           
          
            e.Result = e.Parameter + "|0|" + msg;
        }
        #endregion

        /// <summary>
        /// TAB页签改变事件
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void ASPxPageControl1_ActiveTabChanged(object source, TabControlEventArgs e)
        {
            ClearDataSource(ASPxPageControl1.ActiveTabIndex);
            if (hidYhh_id.Value == "") { return; }//20190411 add 如果用户信息为空，会报异常
            int id = Convert.ToInt32(hidYhh_id.Value);
            DataTable DTYH = _YS_YG_YONGHUXXBLL.SelectYS_YG_YONGHUXXesDynamic(string.Format("ID={0}", id), null);
            string yhh = DTYH.Rows.Count > 0 ? DTYH.Rows[0]["S_YONGHUH"].ToString() : "";
            if (yhh != "")
            {
                switch (ASPxPageControl1.ActiveTabIndex)
                {
                    case 0:
                        gvYongHuXXTab1.DataSource = this.dtYongHuXXTab1;
                        gvYongHuXXTab1.DataBind();
                        gvYongHuXXTab1.FocusedRowIndex = -1;
                        gvYongHuXXTab1.FocusedRowIndex = 0;
                        break;
                  
                    case 1:
                        LoadGridDataTab3("全部", "", 0, yhh);
                        break;
                    
                    default: break;
                }
            }
        }

    }
}